<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

	<style type="text/css">
		*{
			margin: 0;
			padding: 0;
		}
	
		.outer {
			width :80% ;
			margin: 0 auto ;
		}
	</style>
</head>
	
	
	
<body>
	
	
	
	<div class="outer">
		<div>
			<h2>商品列表</h2>
			<p>管理员 :${userInfo.realname }</p>
		</div>
		
		<hr />
		<div>
			<form action="${pageContext.request.contextPath }/per/list" method="post">
			
				商品名称 :<input type="text" name="gname" id="gname" value="${gname }" />
				
				商品类型:<select name="tid" id="tid">
							<option value="0">==请选择==</option>
							<c:forEach var="t" items="${types }">
								<option value="${t.tid }"  <c:if test="${t.tid == tid }">selected</c:if>    >==${t.tname }==</option>
							</c:forEach>
				       </select>
				<input type="submit" value="搜索">
			</form>
		</div>
		
		<hr />
		<div>
			
			<table border=1 width="100%">
				<tr>
					<th>
						<input type="checkbox">
					</th>
					<th>编号</th>
					<th>名称</th>
					<th>图像</th>
					<th>价格</th>
					<th>库存</th>
					<th>生产日期</th>
					<th>状态</th>
					<th>产品类型</th>
					
					<th>
						<A href="">添加</A>
					</th>
				</tr>
				
				<c:if test="${empty pu.lists }">
					<tr>
						<td colspan="10">没有数据</td>
					</tr>
				</c:if>
				<c:if test="${not empty pu.lists }">
					<c:forEach var="g" items="${pu.lists }">
						<tr>
							<th>
								<input type="checkbox" name="flag" value="${g.gid }">
							</th>
							<th>${g.gid }</th>
							<th>${g.gname }</th>
							<th>
								<img alt="图片" src="${pageContext.request.contextPath }/img/${g.imgPath}">
							</th>
							<th>${g.price }</th>
							<th>${g.count }</th>
							<th>
								<fmt:formatDate value="${g.createDate }" pattern="yyyy-MM-dd"/>
							</th>
							<th>
								<c:choose>
									<c:when test="${g.status == '0' }">下架</c:when>
									<c:when test="${g.status == '1' }">上架</c:when>
								</c:choose>
							</th>
							<th>${g.gType.tname }</th>
							
							<th>
								<A href="">添加</A>
							</th>
						</tr>
					</c:forEach>
				</c:if>
				
				
				
			</table>
			
			
		</div>
		<hr />
		<div>
			当前 :${pu.pageNow }/${pu.pageCount }页 
			总计 :${pu.rowCount } 条
			
			<button onclick="page(1)">首页</button>
			<button onclick="page(${pu.prevPage})">上一页</button>
			<button onclick="page(${pu.nextPage})">下一页</button>
			<button onclick="page(${pu.pageCount})">位页</button>
		</div>
	</div>
	
	<script type="text/javascript">
		
		function page(i){
			var gname = document.getElementById("gname").value ;
			var tid = document.getElementById("tid").value ;
			
			location = '${pageContext.request.contextPath }/per/list?pageNow='+i+"&gname="+gname +"&tid="+tid;
		}
	
	</script>
	
</body>
</html>